<!DOCTYPE html>
<html>
 <head>
  <title> new document </title>
  <meta charset="utf-8">
 </head>
 <body>
	<h1>操作元素的属性</h1>
	<img src="img/1.jpg" alt="1">
	<!--      img/2.jpg       2
						img/3.jpg       3
						img/4.jpg       4
					  img/1.jpg       1-->
	<script src="js/jquery-1.11.3.js"></script>
	<script>
		//单击图片，切换下一张
		$("img").on("click",function(){
			var $img=$(this)
			var i=parseInt($img.attr("alt"))
					//parseInt($img.prop("alt"))
			i++;
			if(i>4) i=1;
			$img.attr({
				"src":`img/${i}.jpg`, //.prop
				"alt":i
			})
		})
	</script>
 </body>
</html>
